package test;

import java.util.Arrays;
import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
//        while (in.hasNextInt()) { // 注意 while 处理多个 case
//            int a = in.nextInt();
//            int b = in.nextInt();
//            System.out.println(a + b);
//        }
        int n = in.nextInt();
        int[] nums = new int[n];

        for(int i = 0;i<n;i++){
            nums[i] = in.nextInt();
        }

        Main mymain = new Main();

        System.out.println(mymain.myans2(n,nums));
    }

    public int myans1(){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(),x = sc.nextInt(),y = sc.nextInt();
        int nums[] = new int[n];
        for(int i=0;i<n;i++){
            nums[i]=sc.nextInt();
        }
        if(2*x>n||2*y<n){
            System.out.println(-1);
            return -1;
        }
        Arrays.sort(nums);
        //右端缩小
        if(x+y>=n){
            System.out.println(nums[x-1]);
            return nums[x-1];
        }else{
            System.out.println(nums[n-y-1]);
            return nums[n-y-1];
        }
    }

    public int myans2(int n,int[] nums){
        int val = 0;
        Arrays.sort(nums);
        for(int i = 1;i<=n;i++){
            if(i != nums[i-1]){
//                if(nums[i-1] <= i){
//                    val += i - nums[i-1];
//                }else {
//                    val += nums[i-1]-i;
//                }
                val += Math.abs(i-nums[i-1]);
            }
        }

        return val;
    }

    public void myans3(){

        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        int N = sc.nextInt();
        boolean[][] cook = new boolean[N][2];
        String people = sc.nextLine();
        char[] peoples = people.toCharArray();
        for(int i = 0;i<N;i++){
            if(peoples[i] == '0'){
                continue;
            }else if(peoples[i] == '1'){
                cook[i][0] = true;
            }else {
                cook[i][0] = true;
                cook[i][1] = true;
            }
        }
        int inputPeople = sc.nextInt();
        String queue = sc.nextLine();
        char[] queues = queue.toCharArray();

        for(int i = 0;i<inputPeople;i++){
            if(peoples[i] == 'M'){
                for(int j = 0;j<N;j++){
                    if(cook[i][0]){

                    }
                }
            }
        }
    }
}